package com.swanclouds.api.client;

import com.swanclouds.api.CloudProvider;
import com.swanclouds.api.RedfishClient;
import com.swanclouds.api.exceptions.AuthenticationException;
import com.swanclouds.core.transport.Config;

/**
 * Redfish Client Builder
 *
 * @author Jeremy Unruh
 */
public interface IOSClientBuilder<R, T extends IOSClientBuilder<R, T>> {

    /**
     * Associates the given configuration with this Client
     *
     * @param config Http configuration options
     * @return self for method chaining
     */
    T withConfig(Config config);

    /**
     * The authentication credentials
     *
     * @param userId the user id to authenticate with
     * @param password the password to authenticate with
     * @return self for method chaining
     */
    T credentials(String userId, String password);

    /**
     * The identity endpoint to connect to
     *
     * @param endpoint the endpoint URL of the identity service
     * @return self for method chaining
     */
    T endpoint(String endpoint);

    /**
     * The OpenStack cloud provider which helps determine compatibility within
     * requests
     *
     * @param provider the cloud provider
     * @return self for method chaining
     */
    T provider(CloudProvider provider);


    /**
     * @deprecated :Use to configure SSL policies
     *
     * In some private environments self signed certificates are used. If you
     * are using HTTPS and using self-signed cerificates then set this to true.
     * Otherwise the default strict hostname and properly signed validation
     * based client will be used.
     *
     * @param useNonStrictSSL true if an HTTPS self-signed environment
     * @return self for method chaining
     */
    @Deprecated
    T useNonStrictSSLClient(boolean useNonStrictSSL);

    /**
     * 是否加载 redfish 版本信息
     * @param loadVersion load version in token
     * @return self for method chaining
     */
    T loadVersion(boolean loadVersion);

    /**
     * Attempts to connect, authenticated and obtain an authorization access
     * entity which contains a token, service catalog and endpoints from the
     * controller. As a result a client will be returned encapsulating the
     * authorized access and corresponding API access
     *
     * @return the authenticated client
     * @throws AuthenticationException if the credentials or default tenant is invalid
     */
    R authenticate() throws AuthenticationException;

    /**
     * Redfish Client builder which authenticates against version V1
     */
    public interface V1 extends IOSClientBuilder<RedfishClient.OSClientV1, V1> {

        /**
         * The authentication credentials and default scoped domain
         *
         * @param userName the user name to authenticate with
         * @param password the password to authenticate with
         * @param domain the domain if using "default scoped"
         * @return self for method chaining
         */
        V1 credentials(String userName, String password, String domain);

        /**
         * A token object. With token authentication, the id uniquely identifies
         * the token. This method is typically used in combination with a
         * request to change authorization scope
         *
         * @param tokenId the token identifier
         * @return self for method chaining
         */
        V1 token(String tokenId);

    }

}
